package com.kasax.httpclient.interceptors;

import com.kasax.httpclient.beans.Response;
import com.kasax.httpclient.core.inters.Call;
import com.kasax.httpclient.core.inters.Interceptor;
import com.kasax.httpclient.utils.LogUtils;

import java.io.IOException;

public class RetryAndFlowUpInterceptor implements Interceptor {
    @Override
    public Response intercpt(Chain chain) throws IOException {
        LogUtils.i(getClass(), "intercpt");
        Call call = chain.call();
        int retrys = call.client().retrys();
        IOException exception = null;
        for (int i = 0; i < retrys; i++) {
            if (call.isCanceled()) {
                throw new IOException("Canceled");
            }
            return chain.procced();
        }
        throw exception;

    }
}
